using System;
using System.Collections.Generic;
using System.Text;
using System.Net;

namespace Billing.Net
{
    public static class NetInfo
    {
        public static string UserHostAddress
        {
            get
            {
                return IPAddress[0].ToString();
                //string res = string.Empty;
                //try
                //{
                //    res = System.Web.HttpContext.Current.Request.UserHostAddress;
                //}
                //catch
                //{
                //    res = IPAddress[0].ToString();
                //}
                //return res;
            }
        }
        public static IPAddress[] IPAddress
        {
            get
            {
                return Dns.GetHostEntry(HostName).AddressList;
            }
        }
        public static string HostName
        {
            get
            {
                return Dns.GetHostName();
            }
        }
        public static string HostNameOrIPAddress
        {
            get
            {
                IPAddress[] i = IPAddress;
                if (i.Length == 0) return HostName;
                return i[0].ToString();
            }
        }
    }
}